/**
 * 
 */
package com.grupit.module.user.web.gwt.client.pluggablefeatures.activity;

import com.google.gwt.activity.shared.AbstractActivity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.grupit.api.core.control.activity.PluggableFeatureActivity;
import com.grupit.api.web.gwt.client.control.activity.PrefetchActivity;
import com.grupit.engine.util.FormatterLogger;
import com.grupit.module.user.web.gwt.client.pluggablefeatures.ui.NoteBoardViewImpl;

/**
 * @author jlp
 * 
 */
public class NoteBoardActivity extends AbstractActivity implements PrefetchActivity, PluggableFeatureActivity {

	private static FormatterLogger logger = FormatterLogger.getLogger(NoteBoardActivity.class);

	private NoteBoardViewImpl display;

	public NoteBoardActivity() {
		this.display = new NoteBoardViewImpl();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.google.gwt.activity.shared.Activity#start(com.google.gwt.user.client
	 * .ui.AcceptsOneWidget, com.google.gwt.event.shared.EventBus)
	 */
	@Override
	public void start(AcceptsOneWidget panel, EventBus eventBus) {
		logger.info("Iniciando tablon de notas...");

		/**
		 * Mostramos la vista
		 */
		panel.setWidget(display);

		logger.info("... tablon de notas iniciado.");
	}

	@Override
	public void prefetch(com.google.web.bindery.event.shared.EventBus eventBus) {
		logger.entering("prefetch");

//		globalFlowController.eventBus().bindEvent(display, Event.LoggedUserChanged,
//				new EventHandler<GrupitGlobalFlowController.Event>() {
//
//					@Override
//					public void handleEvent(Object sender, Event event, Object... params) {
//						LoggedUserEventChangeType changeType = (LoggedUserEventChangeType) params[0];
//						onLoggedUserChanged(changeType);
//					}
//				});

		logger.exiting("prefetch");
	}

	@Override
	public void refresh() {
		this.display.poZitPanel().refresh();
	}

}
